package com.itboye.textileexpes.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.ColletionFenyeBeans;
import com.itboye.textileexpes.beans.GoodsBean;
import com.itboye.textileexpes.interfaces.ICollocetion;
import com.itboye.textileexpes.interfaces.IGoods;
import com.itboye.textileexpes.repository.CollectionRepository;
import com.itboye.textileexpes.repository.GoodsRepository;
import com.itboye.textileexpres.base.BasePresenter;
import com.itboye.textileexpres.base.ResultEntity;

public class ColloctionPresenter extends BasePresenter implements
		ICollocetion<ColletionFenyeBeans> {
	public static final String ColloctFenye_success = MainPresenter.class
			.getName() + "_ColloctFenye_success";
	public static final String ColloctFenye_fail = MainPresenter.class
			.getName() + "_ColloctFenye_fail";
	public static final String ColloctDelete_success = MainPresenter.class
			.getName() + "_ColloctDelete_success";
	public static final String ColloctDelete_fail = MainPresenter.class
			.getName() + "_ColloctDelete_fail";
	public static final String ColloctTop_success = MainPresenter.class
			.getName() + "_ColloctTop_success";
	public static final String ColloctTop_fail = MainPresenter.class.getName()
			+ "_ColloctTop_fail";
	public static final String ColloctCate_success = MainPresenter.class
			.getName() + "_ColloctCate_success";
	public static final String ColloctCate_fail = MainPresenter.class.getName()
			+ "_ColloctTop_fail";
	public static final String ColloctAdd_success = MainPresenter.class
			.getName() + "_ColloctAdd_success";
	public static final String ColloctAdd_fail = MainPresenter.class.getName()
			+ "_ColloctAdd_fail";

	public static final String ColloctOrder_fail = MainPresenter.class
			.getName() + "_ColloctOrder_fail";
	public static final String ColloctOrder_success = MainPresenter.class
			.getName() + "_ColloctAdd_success";

	public static final String Update_fail = MainPresenter.class.getName()
			+ "_Update_fail";
	public static final String Update_success = MainPresenter.class.getName()
			+ "_Update_success";

	public static final String Info_fail = MainPresenter.class.getName()
			+ "_Info_fail";
	public static final String Info_success = MainPresenter.class.getName()
			+ "_Info_success";

	public static final String Creat_fail = MainPresenter.class.getName()
			+ "_Creat_fail";
	public static final String Creat_success = MainPresenter.class.getName()
			+ "_Creat_success";

	// 不感兴趣
	public static final String Delete_success = MainPresenter.class.getName()
			+ "_Delete_succ";
	public static final String Delete_fai = MainPresenter.class.getName()
			+ "_Delete_fail";

	public static final String Add_success = MainPresenter.class.getName()
			+ "_Add_succ";
	public static final String Add_fai = MainPresenter.class.getName()
			+ "_Add_fail";

	public ColloctionPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctAdd_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctAdd_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.add(model);
	}

	@Override
	public void delete(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctDelete_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctDelete_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.delete(model);
	}

	@Override
	public void update(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctTop_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctTop_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.update(model);
	}

	@Override
	public void getInfo(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub

		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Info_fail);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Info_success);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.getInfo(model);
	}

	@Override
	public List<ColletionFenyeBeans> query(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void FenYeQuery(String uid, String page_size, String page_index,
			String keyword, String cate_id, String fav_type) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctFenye_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctFenye_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.FenYeQuery(uid, page_size, page_index, keyword, cate_id,
				fav_type);
	}

	@Override
	public void CollectionCateType(String uid) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctCate_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctCate_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.CollectionCateType(uid);
	}

	@Override
	public void CollectOrder(String uid, String pid) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctOrder_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctOrder_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.CollectOrder(uid, pid);
	}

	@Override
	public void oncreate(String uid, String p_ids, String contact_name,
			String note) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Creat_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Creat_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.oncreate(uid, p_ids, contact_name, note);

	}

	@Override
	public void onDeleteNoInterested(String uid, String id) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Delete_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Delete_fai);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.onDeleteNoInterested(uid, id);
	}

	@Override
	public void onAddLike(String uid, String id, String f_type) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Add_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Add_fai);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.onAddLike(uid, id, f_type);
	}

}
